package com.hnzq.cloud.repo;

import com.hnzq.cloud.entity.FreGoods;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;


public interface FreGoodsRepo extends ElasticsearchRepository<FreGoods,Object> {


    @Query("{\n" +
            "       \"multi_match\":{\n" +
            "           \"query\":\"?0\",\n" +
            "           \"fields\":[\"goodsName\"]\n" +
            "       }\n" +
            "   }"
    )
    List<FreGoods> selectGoodsByName(String name);

    @Query("{\n" +
            "       \"multi_match\":{\n" +
            "           \"query\":\"?0\",\n" +
            "           \"fields\":[\"goodsName\",\"goodsMessage\",\"goodsAddr\"]\n" +
            "       }\n" +
            "   }"
    )
    Page<FreGoods> selectGoodsByKeyword(String keyword,Pageable pageable);


    @Query("{\n" +
            "       \"multi_match\":{\n" +
            "           \"query\":\"?0\",\n" +
            "           \"fields\":[\"typeName\"]\n" +
            "       }\n" +
            "   }"
    )
    List<FreGoods> selectGoodsByTypeName(String typeName);
}
